package com.jianggujin.redis.panel.value;

import java.awt.BorderLayout;

import javax.swing.JPanel;

import com.jianggujin.redis.component.JEditorTable;
import com.jianggujin.redis.node.RedisKey;
import com.jianggujin.redis.panel.ValuePanel;

public class ListValuePanel extends JPanel implements ValuePanel {
    private JEditorTable valueTable;

    public ListValuePanel() {
        super(new BorderLayout());
        valueTable = new JEditorTable(new String[] { "Value", "Action" });
        valueTable.setRowSelectionAllowed(false);
//        valueTable.setCellRenderer(1, new AddAndRemoveRenderer());
//        valueTable.setCellEditor(1, new AddAndRemoveEditor());
        add(valueTable);
    }

    @Override
    public void showValue(RedisKey redisKey) {
        valueTable.removeAllRow();
        for (String item : redisKey.getClient().lrange(redisKey.getKey(), 0, -1)) {
            valueTable.addRow(new Object[] { item, "" });
        }
    }
}
